<script>
    /****************************Check*Form*Valid********************************/
    $(function(){
        $("#formcheck").validate({
            rules: {
                titre: "required",
                categorie: "required",
                description: "required"
            },
            messages: {
                titre: "Ce champ est obligatoire !",
                categorie: "Ce champ est obligatoire !",
                txtDes: "Ce champ est obligatoire !"
            }
        });
    });
</script>
<?php
    $selected_cate = 1;
   if($query->num_rows()>0){
        $row = $query->row();
        $id = $row->id;
        $selected_cate = $row->cat;
        $title = $row->title;
        $file_name = $row->image;
        $des = $row->content;
    }   
    //$selected_cate = isset($news_cat)?$news_cat:1; 
    $selected_cate_setting = array
    (
        'table_name' => 'categories',
        'key_field' => 'id',
        'value_field' => 'name'
    );    
?>
<div align="center" class="information"></div>
<table class="titrepage" width="1000px">
    <tr>              
        <td width="300px">La liste des News</td>
        <td><a class="titrea" href="<?php echo site_url('avis_admin/list_categories')?>">La liste des Categories</a></td>
        <td><a class="titrea" href="<?php echo site_url('avis_admin/post_news')?>">Post news</a></td>
        <td align="right">Total | <?php echo $this->db->count_all('news');?></td>
    </tr>
</table>
<br/>
<div style="margin:10px 0px 10px 0px;">
    <?php echo $error?>
    <form id="formcheck"  method="POST" action="<?php echo site_url('avis_admin/update_news').'/'.$id?>" enctype="multipart/form-data">
        <table width="100%" id="formactu" cellpadding="10px" cellspacing="0">
            <tr>
                <td><span>Titre </span></td>
                <td><input  type="text" size="50"  name="titre" value="<?php echo $title?>" ><br/></td>
            </tr>
            <tr>
                <td><span>Image </span></td>
                <td><img src="<?php echo base_url().'assets/news_img/'.$file_name;?>" alt="" width="90" height="60" /><input type="file" name="userfile" /></td>
            </tr>
            <tr>
                <td><span>Categories </span></td>
                <td>
                    <?php echo form_dropdown('categorie',dropdown_data($selected_cate_setting),$selected_cate,'style="width: 310px;"');?>
                </td>
            </tr>
            <tr>
                <td><span>Description </span></td>
                <td>
                <?php                                                                 
                    $data = array('name' => 'txtDes',
                    'id' => 'txtDes',
                    'width' => '600',
                    'height' => '400',
                    'value' =>$des);
                    echo form_fckeditor($data);
                ?>
                </td>
            </tr>
            <tr><td><input type="image"  border="0" src="images/ajouter.png" name="submit"  value="Submit" alt="Submit"></td>
            </tr>
        </table>
    </form>
</div>